home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 354 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: aargh.incubus.sub.org!marc
  2. From: marc@aargh.incubus.sub.org (Marc 'Nepomuk' Heuler)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Serial Device -> ReadLine ?
  5. Message-ID: <F2yUx*rha@aargh.incubus.sub.org>
  6. Date: Sat, 06 Jan 1996 11:40:25 CET
  7. Reply-To: marc@aargh.incubus.sub.org
  8. References: <flohoff.0660@dataland.owl.de>
  9. Organization: Data Design
  10. X-Newsreader: Arn V1.03a
  11.  
  12. In article <flohoff.0660@dataland.owl.de>, Florian Lohoff writes:
  13.  
  14. > i want a routine which sends me (In best case) every time a ExecMsg when
  15. > received a full line from the serial device. What is the best way to do this.
  16. > My thought.
  17. > 1. Read only one char at a time. Put it sequentially in a buffer until $0a/$0d
  18. > 2. Use EOFMode. As i understand from AutoDocs the eofmode made Interrupt
  19. >    receiving. I wasn`t able to get this to run.
  20.  
  21. EOF mode is bad since it is not supported by all serial expansion boards
  22. (at least the A2232 and GVP-IO with old driver software).
  23.  
  24. You could spawn a child task for serial communication:
  25.  
  26. The  child  task  SDCMD_QUERYs the port for data.  If no data is available,
  27. the  task  CMD_READs  1  byte.  Otherwise it reads that many bytes that are
  28. available.
  29.  
  30. The  task  reads  to  a circular buffer of x bytes length.  X should be the
  31. number  of  bytes  that can appear in one line maximum, plus a large safety
  32. margin for line noise.  A dropped (internal serial port!) EOL character for
  33. example can double the line size.  Do check the size before reading!
  34.  
  35. After a read has completed, the task should scan the circular buffer for an
  36. EOL  character.   If  it  finds  one,  it  sends copies the line to an exec
  37. message  and sends it to your main task - and marks that part of the buffer
  38. as free.
  39.  
  40. If the buffer overflows (no more free bytes, but no EOL char inside), it
  41. must be cleared, paying data loss to prevent hangs.
  42.  
  43. The child task should respond to ^C by cleaning up and exiting.
  44.